package com.hzw.saas.service.user.service;

import cn.hutool.core.util.StrUtil;
import com.hzw.saas.api.user.IChannelCommonService;
import com.hzw.saas.api.user.IStaffService;
import com.hzw.saas.api.user.bo.StaffBO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * <p>
 *
 * </p>
 *
 * @author sonam
 * @since 2021/5/8 14:24
 */
@RequiredArgsConstructor
@Service("staffChannelCommonServiceImpl")
public class StaffChannelCommonServiceImpl implements IChannelCommonService {

    @Resource(name = "staffServiceImpl")
    private IStaffService staffService;

    @Override
    public String getChannelDesc(String channelId) {
        if(StrUtil.isBlank(channelId)) {
            return StrUtil.EMPTY;
        }

        StaffBO staffBo = staffService.getById(channelId);
        if(Objects.isNull(staffBo)) {
//            if(AccountValidatorUtil.isMobile(channelId)) {
            staffBo = staffService.queryByPhoneNo(channelId);
//            }
            if(Objects.isNull(staffBo)) {
                return StrUtil.EMPTY;
            }
        }

        return staffBo.getStaffName();
    }

}
